import React, { Component } from 'react'

export default class Hello extends Component {
  constructor(props) {
    super(props)
    this.state = { count: 0 }
  }

  increment = () => {
    //同一个方法中 多次短时间执行多个setState
    for (let i = 0; i < 1000; i++) {
      this.setState({
        count: ++this.state.count
      })
    }
  }

  render () {
    const { count } = this.state
    return (
      <div>
        <button onClick={this.increment}> + </button>
        <p>{count}</p>
      </div>
    )
  }
}
